package safari.model.transaction;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;

import safari.model.member.MemberVO;


public class TransactionDaoImpl implements TransactionDao {
	private SqlSessionTemplate sqlSessionTemplate;
	public TransactionDaoImpl(SqlSessionTemplate sqlSessionTemplate){
		this.sqlSessionTemplate=sqlSessionTemplate;
	}
	@Override
	public void updateBuyer(TransactionVO tvo) throws SQLException {
		sqlSessionTemplate.update("transaction.updateBuyer", tvo);
	}

	@Override
	public void updateSeller(TransactionVO tvo) throws SQLException {
		sqlSessionTemplate.update("transaction.updateSeller", tvo);
	}

	@Override
	public void updateSellStatus(String sellStatus, int sellNo) throws SQLException {
		Map map=new HashMap();
		map.put("sellStatus", sellStatus);
		map.put("sellNo", sellNo);
		sqlSessionTemplate.update("transaction.updateSellStatus", map);
	}

	@Override
	public void insertTradeHistory(TradeHistoryVO thvo) throws SQLException {
		sqlSessionTemplate.insert("transaction.insertTradeHistory", thvo);

	}
	@Override
	public int selectBalance(String buyerId) throws SQLException {
		return sqlSessionTemplate.selectOne("transaction.selectBalance", buyerId);
	}
	@Override
	public MemberVO selectMember(String buyerId) throws SQLException {
		return sqlSessionTemplate.selectOne("member.getinfo", buyerId);
	}

}
